import Vue from "vue"
import Router from "vue-router"
Vue.use(Router)


const Login = () => import("views/Login.vue")
const Logindex = () => import("views/Logindex.vue")
const ForgetLoginPassword = () => import("views/ForgetLoginPassword.vue")
const SMSVerification = () => import("views/SMSVerification.vue")

const Register = () => import("views/Register.vue")
const Invitees = () => import("views/Invitees.vue")
const TabBar = () => import("views/Tabbar.vue")

const OpenWeb = () => import("views/OpenWeb.vue")

// 主界面
const Home = () => import("views/Home.vue")
const Shares = () => import("views/Shares.vue")
const Mine = () => import("views/Mine.vue")
//首页
const CustomerService = () => import("views/home/CustomerService.vue")
const Problem = () => import("views/home/Problem.vue")
const FeedBack = () => import("views/home/FeedBack.vue")
const OnlineCollection = () => import("views/home/OnlineCollection.vue")
// 分享
const ShareImg = () => import("views/share/ShareImg.vue")
const ShareImgx = () => import("views/share/ShareImgx.vue")
const HandBook = () => import("views/share/HandBook.vue")
const NewsInfo = () => import("views/share/NewsInfo.vue")
const CentralCopywriter = () => import("views/share/CentralCopywriter.vue")

const MyBankh = ()=> import("../views/share/MyBankh.vue")
// 我的
const UserInfo = () => import("views/mine/UserInfo.vue")
const BindingZfb = () => import("views/mine/BindingZFB.vue")
const ChoiceRealName = () => import("views/mine/ChoiceRealName.vue")
const BankCard = () =>import("views/mine/BankCard.vue")
const Wallet = () => import("views/mine/Wallet.vue")
const SetUp = () => import("views/mine/SetUp.vue")
const AboutUs = () => import("views/mine/AboutUs.vue")
const ChangePassword = ()=> import("views/mine/ChangePassword.vue")
const ResetTransactionPwd = () => import("views/mine/ResetTransactionPwd.vue")
const IncomeRanking = ()=>import("views/mine/IncomeRanking.vue")
const MyRate = () => import("views/mine/MyRate.vue")
const MySpread = () => import("views/mine/MySpread.vue")
const MemberDetail = () => import("views/mine/MemberDetail.vue")
const MemberDetailList = () => import("views/mine/MemberDetailList.vue")
const AddCreditCard = () => import("views/mine/AddCreditCard.vue")
const AddStorageCard = () => import("views/mine/AddStorageCard.vue")
const UpdateCreditCard = () => import("views/mine/UpdateCreditCard.vue")
const UpdateModificationCard = () => import("views/mine/UpdateModificationCard.vue")
const TransactionDetails = () =>import("views/mine/TransactionDetails.vue")
const Profit = () =>import("views/mine/Profit.vue")
const TransferOut = () => import("views/mine/TransferOut.vue")
const IncomeDetails = () => import("views/mine/IncomeDetails.vue")
const IncomeDetailsItem  = () => import("views/mine/IncomeDetailsItem.vue")
const ReturningAServant = () => import("views/mine/ReturningAServant.vue")
const RebateDetails = () => import("views/mine/RebateDetails.vue")
const OrderDetail = () => import("views/mine/OrderDetail.vue")


const ProductUpgrade =()=> import("views/ProductUpgrade.vue")
const ProductDetail = () => import("views/ProductDetail.vue")

const RealNameCertification = () => import("views/mine/RealNameCertification.vue")


const routes = [
    {
        path: "/",
        redirect: "/logindex"
    },
    {
        path:"/mybankh",
        name:"MyBankh",
        component:MyBankh
    },
    {
        path:"/onlinecollection",
        name:"OnlineCollection",
        component:OnlineCollection
    },
    {
        path:"/productdetail",
        name:"ProductDetail",
        component:ProductDetail
    },
    {
        path:"/productupgrade",
        name:"ProductUpgrade",
        component:ProductUpgrade
    },
    {
        path:"/orderdetail",
        name:"OrderDetail",
        component:OrderDetail
    },
    {
        path:"/rebatedetails",
        name:"RebateDetails",
        component:RebateDetails
    },
    {
        path:"/returningaservant",
        name:"ReturningAServant",
        component:ReturningAServant
    },
    {
        path:"/incomedetailsitem",
        name:"IncomeDetailsItem",
        component:IncomeDetailsItem
    },
    {
        path:"/incomedetails",
        name:"IncomeDetails",
        component:IncomeDetails
    },
    {
        path:"/transferout",
        name:"TransferOut",
        component:TransferOut
    },
    {
        path:"/profit",
        name:"Profit",
        component:Profit
    },
    {
        path:"/transactiondetails",
        name:"TransactionDetails",
        component:TransactionDetails
    },
    {
        path:"/updatemodificationcard",
        name:"UpdateModificationCard",
        component:UpdateModificationCard
    },
    {
        path:"/updatecreditcard",
        name:"UpdateCreditCard",
        component:UpdateCreditCard
    },
    {
        path:"/addcreditcard",
        name:"AddCreditCard",
        component:AddCreditCard
    },
    {
        path:"/addstoragecard",
        name:"AddStorageCard",
        component:AddStorageCard
    },
    {
        path:"/myspread",
        name:MySpread,
        component:MySpread
    },
    {
        path: "/customerService",
        component: CustomerService
    },
    {
        path: "/login",
        component: Login
    },
    {
        path: "/logindex",
        component: Logindex
    },
    {
        path: "/forgetLoginPassword",
        component: ForgetLoginPassword
    },
    {
        path: "/sMSVerification",
        name: "SMSVerification",
        component: SMSVerification
    },
    {
        path: "/home",
        component: Home
    },
    {
        path:"/bankcard",
        component:BankCard
    },
    {
        path: "/problem",
        name: "Problem",
        component: Problem
    },
    {
        path: "/feedback",
        component: FeedBack
    },
    {
        path: "/shares",
        component: Shares
    },
    {
        path: "/shareimg",
        component: ShareImg
    },
    {
        path: "/shareimgx",
        component: ShareImgx
    },
    {
        path: "/centralcopywriter",
        component: CentralCopywriter
    },
    {
        path: "/openweb",
        name: "OpenWeb",
        component: OpenWeb
    },
    {
        path: "/newsinfo",
        component: NewsInfo
    },
    {
        path: "/tabbar",
        component: TabBar
    },
    {
        path: "/mine",
        component: Mine
    },
    {
        path:"/memberdetail",
        name:"MemberDetail",
        component:MemberDetail
    },
    {
        path:"/memberdetaillist",
        name:"MemberDetailList",
        component:MemberDetailList
    },
    {
        path:"/myrate",
        component:MyRate
    },
    {
        path:"/incomeranking",
        component:IncomeRanking
    },
    {
        path:"/setup",
        component:SetUp
    },
    {
        path:"/changepassword",
        component:ChangePassword
    
    },
    {
        path:"/resettransactionpwd",
        component:ResetTransactionPwd
    },
    {
        path:"/aboutus",
        component:AboutUs
    },
   {
       path:"/wallet",
       component:Wallet
   },
    {
        path: "/realnamecertification",
        component: RealNameCertification
    },
    {
        path: "/choicerealname",
        component: ChoiceRealName
    },
    {
        path: "/userinfo",
        component: UserInfo
    },
    {
        path: "/bindingzfb",
        component: BindingZfb
    },
    {
        path: "/register",
        component: Register
    },
    {
        path: "/invitees",
        component: Invitees
    },
    {
        path: "/handbook",
        component: HandBook
    }
]

const router = new Router({
    routes,
    mode: "history"
})

router.beforeEach((to,from,next)=>{
    // to 将要访问那个位置
    // from  从哪个路径过来
    // next  放行
    if(to.path == "/logindex" ) return next();
    const toke = window.localStorage.getItem("token");
    if(!toke) return next("/logindex");
    next();

})

export default router